package com.af.security.property;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import javax.annotation.PostConstruct;

/**
 * @author : zhenyun.su
 * @since : 2019/5/30
 * @common:
 * name; 项目名称
 * version; 版本号，取值pom.xml
 * serverUrl; 部署后服务地址，用于在发送激活账号及重置密码邮件时，自带链接地址，需要的访问主机。
 */

@Configuration
@ConfigurationProperties(prefix="asu.project")
public class ProjectProperties {
    private static final Logger logger = LoggerFactory.getLogger(ProjectProperties.class);
    private String name;
    private String version;
    private String serverUrl;

    @PostConstruct
    public void print(){
        logger.debug("load sys config from application.yaml, {}", this);
    }

    public String getUrl(String resources){
        return this.getServerUrl()+resources;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getVersion() {
        return version;
    }

    public void setVersion(String version) {
        this.version = version;
    }

    public String getServerUrl() {
        return serverUrl;
    }

    public void setServerUrl(String serverUrl) {
        this.serverUrl = serverUrl;
    }

    @Override
    public String toString() {
        return "ProjectProperties{" +
                "name='" + name + '\'' +
                ", version='" + version + '\'' +
                ", serverUrl='" + serverUrl + '\'' +
                '}';
    }
}
